﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="~/plugins/mzui/js/mzui.min.js"></script>
    <link href="~/plugins/mzui/css/mzui.min.css" rel="stylesheet" />
    <title>商家资料</title>
</head>
<body class="with-nav-bottom">
    <section class="section">
        @using (Html.BeginForm("upshop", "shop", FormMethod.Post, new { @class = "box", enctype = "multipart/form-data" }))
        {
            <div class="control">
                <label>商家类别</label>
                @foreach (var item in Model)
                {
                    <div class="radio inline-block">
                    @if (item.gid == ViewBag.flgid)
                    {
                        <input type="radio" name="flgid" value="@item.gid" checked="checked">
                    }
                    else
                    {
                        <input type="radio" name="flgid" value="@item.gid">
                    }
                    <label for="flgid">@item.name</label>
                    </div>
                }
            </div>
            <div class="control">
                <label>商家封面</label>
                <img id="pictureimg" src="@ViewBag.picture" onerror="this.src = '/images/nopic.png'" />
                <input id="picture" name="file" type="file" class="hidden" />
                <div id="picturebt" class="help-text text-red hidden"></div>
            </div>
            <div class="divider"></div>
            <div class="control">
                最惠待遇 <input id="zhekou" name="zhekou" placeholder="最惠待遇" value="@ViewBag.zhekou" type="text">
                <div id="zkmsg" class="help-text text-red">描述最惠信息,不要超过8个字</div>
            </div>
            <div class="control">
                人均消费 <input id="xfx" name="xfx" value="@ViewBag.xfx" type="text" style="width:50px;text-align:center;" onkeyup="value=value.replace(/[^\d]/g,'');" placeholder="￥最少"> - <input id="xfd" name="xfd" value="@ViewBag.xfd" type="text" style="width:50px;text-align:center;" onkeyup="value=value.replace(/[^\d]/g,'');" placeholder="￥最多">
                <div id="xfmsg" class="help-text text-red"></div>
            </div>
            <div class="divider"></div>
            <div class="control">
                <label>商家名称</label>
                <input id="name" name="name" value="@ViewBag.name" type="text" class="input" placeholder="你的店铺名称">
                <div id="namemsg" class="help-text text-red"></div>
            </div>
            <div class="control">
                <label>商家地址</label>
                <select name="province" id="Province">
                    <option></option>
                </select> -
                <select name="city" id="City">
                    <option></option>
                </select> -
                <select name="area" id="Area">
                    <option></option>
                </select>
                <br />
                <input id="address" name="address" value="@ViewBag.address" type="text" class="input" placeholder="具体路段楼层门牌号">
                <div id="china" class="help-text text-red"></div>
            </div>
            <div class="control">
                <label>联系方式</label>
                <input id="lxfs" name="lxfs" value="@ViewBag.lxfs" type="text" class="input" placeholder="请填写标准的手机或电话号码">
                <div id="lxmsg" class="help-text text-red"></div>
            </div>
            <div class="control">
                <label>商家特色每个特色请用空格分开。(咖啡 糕点)</label>
                <input name="tese" value="@ViewBag.tese" type="text" class="input" placeholder="介绍你店里的特色">
            </div>
            <div class="control">
                <label>商家介绍</label>
                <textarea type="text" name="explain" autocomplete="off" class="input" style="height:5rem;">@ViewBag.explain</textarea>
            </div>
            <div class="control">
                <label>商家详情</label>
                <textarea type="text" name="introduce" autocomplete="off" class="input" style="height:8rem;">@ViewBag.introduce</textarea>
            </div>
        }
    </section>
    <nav class="nav affix dock-bottom justified">
        <a href="/shop/index" class="primary"><i class="icon-5x icon-arrow-left"></i></a>
        <a class="info"></a>
        <a class="info" onclick="return shop();">提交</a>
        <a class="info"></a>
    </nav>
    <script src="~/js/pca.js" charset="gb2312"></script>
    <script src="~/js/image.js"></script>
    <script>
        //设置省市区
        setup();
        if ("@ViewBag.province".length > 0) {
            preselect("@ViewBag.province");
            setTimeout("document.getElementById('City').value = '@ViewBag.city';change(2);", 1000);
            setTimeout("document.getElementById('Area').value = '@ViewBag.area';", 1000);
        }
        //个人资料
        function shop() {
            if (document.getElementById("Province").value == "请选择省份") {
                document.getElementById("china").innerHTML = "请选择省份";
                return false;
            }
            if (document.getElementById("City").value == "请选择城市") {
                document.getElementById("china").innerHTML = "请选择城市";
                return false;
            }
            if (document.getElementById("Area").value == "请选择区域") {
                document.getElementById("china").innerHTML = "请选择区域";
                return false;
            }
            else {
                document.getElementById("china").innerHTML = "";
            }
            if (document.getElementById("zhekou").value.length <= 0) {
                document.getElementById("zkmsg").innerHTML = "最惠待遇必须填写";
                return false;
            }
            else
            {
                document.getElementById("zkmsg").innerHTML = "";
            }
            if (document.getElementById("xfx").value.length <= 0) {
                document.getElementById("xfmsg").innerHTML = "消费范围必须填写";
                return false;
            }
            else {
                document.getElementById("xfmsg").innerHTML = "";
            }
            if (document.getElementById("xfd").value.length <= 0) {
                document.getElementById("xfmsg").innerHTML = "消费范围必须填写";
                return false;
            }
            else {
                document.getElementById("xfmsg").innerHTML = "";
            }
            if (document.getElementById("name").value.length <= 2) {
                document.getElementById("namemsg").innerHTML = "商家名称不少于3个字";
                return false;
            }
            else {
                document.getElementById("namemsg").innerHTML = "";
            }
            if (document.getElementById("address").value.length <= 5) {
                document.getElementById("china").innerHTML = "商家地址不够详细";
                return false;
            }
            else {
                document.getElementById("china").innerHTML = "";
            }
            if (document.getElementById("lxfs").value.length <= 10) {
                document.getElementById("lxmsg").innerHTML = "联系方式不完整";
                return false;
            }
            else {
                document.getElementById("lxmsg").innerHTML = "";
            }
            document.forms[0].submit();
            return true;
        }
        $("#picture").on('change', function () {
            url = "/ajax/api.ashx?ff=shoppicture";
            id = "picture";
            loadImageFile(id);
        });
    </script>
</body>
</html>
